/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.dahg.project.web;

import java.io.Serializable;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import org.jboss.weld.context.RequestContext;



/**
 *
 * @author dahg
 */
public abstract class AbstractWebBean implements Serializable {
    
    public void addInfo(String message) {
        AddMessage(message, FacesMessage.SEVERITY_INFO);
    }
    
    public void addError(String message) {
        AddMessage(message, FacesMessage.SEVERITY_ERROR);
    }
    
    private void AddMessage(String message,FacesMessage.Severity severity) {
        FacesMessage msg = new FacesMessage(severity, message, null);
        getFacesContext().addMessage(null, msg);
    }
    
    private FacesContext getFacesContext() {
        return FacesContext.getCurrentInstance();
    }
    
    public RequestContext getRequestContext() {
        return getRequestContext();
    }
}
